package com.yupi.yupao.once;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.context.AnalysisContext;

import com.alibaba.excel.read.listener.PageReadListener;
import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.util.ListUtils;

import java.io.File;
import java.util.List;

public class ImportExcel {

    public static void main(String[] args) {
        // 写法1：JDK8+ ,不用额外写一个PlanetUserInfoListener
        // since: 3.0.0-beta1
        String fileName = "";
        // 这里默认每次会读取100条数据 然后返回过来 直接调用使用数据就行
        // 具体需要返回多少行可以在`PageReadListener`的构造函数设置

    }



    public static void readByListener(String fileName){
        EasyExcel.read(fileName, PlanetUserInfo.class, new PlanetUserInfoListener()).sheet().doRead();
    }

    public static void synchronousRead(String fileName){
        List<PlanetUserInfo> totalDataList = EasyExcel.read(fileName).head(PlanetUserInfo.class).sheet().doReadSync();
        for (PlanetUserInfo planetUserInfo : totalDataList) {
            System.out.println(planetUserInfo);
        }
    }
}
